package com.hxkj.domain.enums;

import com.platform.common.domain.exception.CustomExceptionCode;

/**
 * 文章异常枚举
 * <p>
 * created by zhuzhenxin on 2017/6/6.
 */
public enum ArticleExceptionEnum implements CustomExceptionCode {
    //异常枚举
    ARTICLE_SAVE_ERRO(600, "发布文章错误", 900),
    ARTICLE_ID_NULL(601, "文章ID为空", 900),
    ARTICLE_TAGS_NULL(602, "tags为空", 900),
    ARTICLE_HEADLINE_NULL(603, "标题为空", 900),
    ARTICLE_SUBHEAD_NULL(604, "副标题为空", 900),
    ARTICLE_SITEID_NULL(605, "站点id为空", 900),
    AUTHROLE_COLUMNID_NULL(606, "文章分类id为空", 900),
    AUTHROLE_TEMPLATEID_NULL(607, "页面模版id为空", 900),
    AUTHROLE_AUTHOR_NULL(608, "作者为空", 900),
    AUTHROLE_ABSTRACTMSG_NULL(609, "摘要简介为空", 900),
    AUTHROLE_PARTICULARS_NULL(610, "详情为空", 900),
    AUTHROLE_DELAG_NULL(611, "删除标示为空", 900),
    AUTHROLE_AUDITTYPE_NULL(612, "审核标识为空", 900),
    AUTHROLE_EVALUATE_NULL(613, "请选择评论权限", 900),
    ARTICLE_MODIFY_ERRO(614, "文章编辑错误", 900),
    ARTICLE_REMOVE_ERRO(615, "文章移除错误", 900),
    ARTICLE_DELETE_ERRO(616, "文章删除错误", 900),
    ARTICLE_GET_ERRO(617, "文章查询错误", 900),
    ARTICLE_GETLIST_ERRO(618, "文章查询列表错误", 900),
    ARTICLE_REPETITION(619, "文章标题重复", 900),
    ARTICLE_AUDIT_ERRO(620, "文章审核错误", 900),
    ARTICLE_CREATETIMESTRAT_NULL(621, "文章开始时间为空", 900),
    ARTICLE_CREATETIMESEND_NULL(622, "文章结束时间为空", 900),
    ARTICLE_ARTICLERECOVER_ERRO(623, "文章恢复错误", 900),
    ARTICLE_IMG_NUMBER1_ERRO(624, "单图只能上传一张图片", 900),
    ARTICLE_IMG_NUMBER3_ERRO(625, "三图只能上传三张图片", 900),
    ARTICLE_COVER_NUMBER_NULL(626, "请选择封面图片上传类型", 900),
    ARTICLE_DETAIL_NUMBER_ERROR(627, "详情内容字符长度不能超过20000，请注意空格空排", 900),
    ARTICLE_STICK_ERRO(628, "文章置顶错误", 900),
    ARTICLE_GETARTICLE1_ERRO(629, "查询新闻推荐，热门百科错误", 900),
    ARTICLE_GETARTICLEMARKET_ERRO(630, "查询期权行情，期权百科错误", 900),
    ARTICLE_GETHOTARTICLE_ERRO(631, "查询热门文章错误", 900),
    EMAIL_IS_NULL(632, "邮箱为空", 900),
    MOBILE_IS_NULL(633, "手机号码为空", 900),
    UUID_IS_NULL(634, "图片验证码的key值uuid为空", 900),
    CODE_IS_NULL(635, "图片验证码为空", 900),
    MSG_IS_NULL(636, "短信验证码为空", 900),
    CODE_IS_ERROR(637, "图片验证码错误", 900),
    MSG_IS_ERROR(638, "短信验证码错误", 900),
    COLUMNID_IS_NULL(639, "分类id为空", 900),
    ARTICLE_IS_NULL(640, "没有获取到文章", 900),
    TAGS_IS_EXIST(340, "tag名称已存在", 900),
    ARTICLE_FREEMARKER_ERRO(341, "文章详情模板解析失败", 900),
    ARTICLE_IMGURL_NOT_NULL(342, "当文章推荐或置顶时，必须上传图片", 900),
    ARTICLE_TAGS_OVER_NUM(343, "亲！tags标签不能超过5个，请用','连接哦", 900),
    ARTICLE_TAG_OVER_LENGTH(344, "亲！单个TAG标签长度不能超过4个字，请重新输入用','连接哦", 900),
    ARTICLE_UPDATE_HEAT_ERROR(345, "亲！您访问的文章不存在哦！", 900),
    ARTICLE_UPDATE_SQL_ERROR(346, "修改文章热度sql错误", 900),
    ARTICLE_NOT_EXIST(347, "文章不存在", 900),
    ;
    private Integer code;
    private String msg;
    private Integer httpCode;

    ArticleExceptionEnum(Integer code, String msg, Integer httpCode) {
        this.code = code;
        this.msg = msg;
        this.httpCode = httpCode;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    @Override
    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public Integer getHttpCode() {
        return httpCode;
    }

    @Override
    public void setHttpCode(Integer httpCode) {
        this.httpCode = httpCode;
    }

    public static ArticleExceptionEnum getEnumByCode(Integer code){
        for(ArticleExceptionEnum articleExceptionEnum : ArticleExceptionEnum.values()){
            if(code.equals(articleExceptionEnum.getCode())){
                return articleExceptionEnum;
            }
        }
        return null;
    }
}
